home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / tankbatt.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  10KB  |  338 lines

  1. /***************************************************************************
  2.  
  3. Tank Battalion memory map (preliminary)
  4.  
  5. driver by Brad Oliver
  6.  
  7. $0000-$000f : bullet ram, first entry is player's bullet
  8. $0010-$01ff : zero page & stack
  9. $0200-$07ff : RAM
  10. $0800-$0bff : videoram
  11. $0c00-$0c1f : I/O
  12.  
  13. Read:
  14.     $0c00-$0c03 : p1 joystick
  15.     $0c04
  16.     $0c07       : stop at grid self-test if bit 7 is low
  17.     $0c0f         : stop at first self-test if bit 7 is low
  18.  
  19.     $0c18        : Cabinet, 0 = table, 1 = upright
  20.     $0c19-$0c1a    : Coinage, 00 = free play, 01 = 2 coin 1 credit, 10 = 1 coin 2 credits, 11 = 1 coin 1 credit
  21.     $0c1b-$0c1c : Bonus, 00 = 10000, 01 = 15000, 10 = 20000, 11 = none
  22.     $0c1d        : Tanks, 0 = 3, 1 = 2
  23.     $0c1e-$0c1f : ??
  24.  
  25. Write:
  26.     $0c00-$0c01 : p1/p2 start leds
  27.     $0c02        : ?? written to at end of IRQ, either 0 or 1 - coin counter?
  28.     $0c03        : ?? written to during IRQ if grid test is on
  29.     $0c08        : ?? written to during IRQ if grid test is on
  30.     $0c09        : Sound - coin ding
  31.     $0c0a        : NMI enable (active low) ?? game only ??
  32.     $0c0b        : Sound - background noise, 0 - low rumble, 1 - high rumble
  33.     $0c0c        : Sound - player fire
  34.     $0c0d        : Sound - explosion
  35.     $0c0f        : NMI enable (active high) ?? demo only ??
  36.  
  37.     $0c10        : IRQ ack ??
  38.     $0c18        : Watchdog ?? Not written to while game screen is up
  39.  
  40. $2000-$3fff : ROM
  41.  
  42. TODO:
  43.     . Resistor values on the color prom need to be verified
  44.  
  45. Changes:
  46.     28 Feb 98 LBO
  47.         . Fixed the coin interrupts
  48.         . Fixed the color issues, should be 100% if I guessed at the resistor values properly
  49.         . Fixed the 2nd player cocktail joystick, had the polarity reversed
  50.         . Hacked the sound sample triggers so they work better
  51.  
  52. Known issues:
  53.     . The 'moving' tank rumble noise seems to keep playing a second too long
  54.     . Sample support is all a crapshoot. I have no idea how it really works
  55.  
  56. ***************************************************************************/
  57.  
  58. #include "driver.h"
  59. #include "vidhrdw/generic.h"
  60. #include "cpu/m6502/m6502.h"
  61.  
  62. extern unsigned char *tankbatt_bulletsram;
  63. extern size_t tankbatt_bulletsram_size;
  64.  
  65. static int tankbatt_nmi_enable; /* No need to init this - the game will set it on reset */
  66. static int tankbatt_sound_enable;
  67.  
  68. void tankbatt_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  69. void tankbatt_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  70.  
  71. WRITE_HANDLER( tankbatt_led_w )
  72. {
  73.     osd_led_w(offset, data);
  74. }
  75.  
  76. READ_HANDLER( tankbatt_in0_r )
  77. {
  78.     int val;
  79.  
  80.     val = readinputport(0);
  81.     return ((val << (7-offset)) & 0x80);
  82. }
  83.  
  84. READ_HANDLER( tankbatt_in1_r )
  85. {
  86.     int val;
  87.  
  88.     val = readinputport(1);
  89.     return ((val << (7-offset)) & 0x80);
  90. }
  91.  
  92. READ_HANDLER( tankbatt_dsw_r )
  93. {
  94.     int val;
  95.  
  96.     val = readinputport(2);
  97.     return ((val << (7-offset)) & 0x80);
  98. }
  99.  
  100. WRITE_HANDLER( tankbatt_interrupt_enable_w )
  101. {
  102.     tankbatt_nmi_enable = !data;
  103.     tankbatt_sound_enable = !data;
  104.     if (data != 0) cpu_clear_pending_interrupts(0);
  105.     /* hack - turn off the engine noise if the normal game nmi's are disabled */
  106.     if (data) sample_stop (2);
  107. //    interrupt_enable_w (offset, !data);
  108. }
  109.  
  110. WRITE_HANDLER( tankbatt_demo_interrupt_enable_w )
  111. {
  112.     tankbatt_nmi_enable = data;
  113.     if (data != 0) cpu_clear_pending_interrupts(0);
  114. //    interrupt_enable_w (offset, data);
  115. }
  116.  
  117. WRITE_HANDLER( tankbatt_sh_expl_w )
  118. {
  119.     if (tankbatt_sound_enable)
  120.         sample_start (1, 3, 0);
  121. }
  122.  
  123. WRITE_HANDLER( tankbatt_sh_engine_w )
  124. {
  125.     if (tankbatt_sound_enable)
  126.     {
  127.         if (data)
  128.             sample_start (2, 2, 1);
  129.         else
  130.             sample_start (2, 1, 1);
  131.     }
  132.     else sample_stop (2);
  133. }
  134.  
  135. WRITE_HANDLER( tankbatt_sh_fire_w )
  136. {
  137.     if (tankbatt_sound_enable)
  138.         sample_start (0, 0, 0);
  139. }
  140.  
  141. static struct MemoryReadAddress readmem[] =
  142. {
  143.     { 0x0000, 0x01ff, MRA_RAM },
  144.     { 0x0c00, 0x0c07, tankbatt_in0_r },
  145.     { 0x0c08, 0x0c0f, tankbatt_in1_r },
  146.     { 0x0c18, 0x0c1f, tankbatt_dsw_r },
  147.     { 0x0200, 0x0bff, MRA_RAM },
  148.     { 0x6000, 0x7fff, MRA_ROM },
  149.     { 0xf800, 0xffff, MRA_ROM },    /* for the reset / interrupt vectors */
  150.     { -1 }    /* end of table */
  151. };
  152.  
  153. static struct MemoryWriteAddress writemem[] =
  154. {
  155.     { 0x0010, 0x01ff, MWA_RAM },
  156.     { 0x0800, 0x0bff, videoram_w, &videoram, &videoram_size },
  157.     { 0x0000, 0x000f, MWA_RAM, &tankbatt_bulletsram, &tankbatt_bulletsram_size },
  158.     { 0x0c18, 0x0c18, MWA_NOP }, /* watchdog ?? */
  159.     { 0x0c00, 0x0c01, tankbatt_led_w },
  160.     { 0x0c0a, 0x0c0a, tankbatt_interrupt_enable_w },
  161.     { 0x0c0b, 0x0c0b, tankbatt_sh_engine_w },
  162.     { 0x0c0c, 0x0c0c, tankbatt_sh_fire_w },
  163.     { 0x0c0d, 0x0c0d, tankbatt_sh_expl_w },
  164.     { 0x0c0f, 0x0c0f, tankbatt_demo_interrupt_enable_w },
  165.     { 0x0200, 0x07ff, MWA_RAM },
  166.     { 0x2000, 0x3fff, MWA_ROM },
  167.     { -1 }    /* end of table */
  168. };
  169.  
  170. int tankbatt_interrupt (void)
  171. {
  172.     if ((readinputport (0) & 0x60) == 0) return interrupt ();
  173.     if (tankbatt_nmi_enable) return nmi_interrupt ();
  174.     else return ignore_interrupt ();
  175. }
  176.  
  177. INPUT_PORTS_START( tankbatt )
  178.     PORT_START    /* IN0 */
  179.     PORT_BIT ( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY )
  180.     PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY )
  181.     PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY )
  182.     PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY )
  183.     PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
  184.     PORT_BIT_IMPULSE( 0x60, IP_ACTIVE_LOW, IPT_COIN1, 2 )
  185.     PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_TILT )
  186.  
  187.     PORT_START    /* IN1 */
  188.     PORT_BIT ( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_4WAY | IPF_COCKTAIL )
  189.     PORT_BIT ( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_4WAY | IPF_COCKTAIL )
  190.     PORT_BIT ( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_4WAY | IPF_COCKTAIL )
  191.     PORT_BIT ( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_4WAY | IPF_COCKTAIL )
  192.     PORT_BIT ( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
  193.     PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_START1 )
  194.     PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_START2 )
  195.     PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
  196.  
  197.     PORT_START    /* DSW */
  198.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ) )
  199.     PORT_DIPSETTING(    0x01, DEF_STR( Upright ) )
  200.     PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
  201.      PORT_DIPNAME( 0x06, 0x06, DEF_STR( Coinage ) )
  202.     PORT_DIPSETTING(    0x04, DEF_STR( 2C_1C ) )
  203.     PORT_DIPSETTING(    0x06, DEF_STR( 1C_1C ) )
  204.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
  205.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  206.     PORT_DIPNAME( 0x18, 0x08, DEF_STR( Bonus_Life ) )
  207.     PORT_DIPSETTING(    0x00, "10000" )
  208.     PORT_DIPSETTING(    0x10, "15000" )
  209.     PORT_DIPSETTING(    0x08, "20000" )
  210.     PORT_DIPSETTING(    0x18, "None" )
  211.     PORT_DIPNAME( 0x20, 0x00, DEF_STR( Lives ) )
  212.     PORT_DIPSETTING(    0x20, "2" )
  213.     PORT_DIPSETTING(    0x00, "3" )
  214.     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
  215.     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
  216.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  217.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
  218.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  219.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  220. INPUT_PORTS_END
  221.  
  222.  
  223. static struct GfxLayout charlayout =
  224. {
  225.     8,8,    /* 8*8 characters */
  226.     256,    /* 256 characters */
  227.     1,    /* 1 bit per pixel */
  228.     { 0 },    /* only one bitplane */
  229.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  230.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  231.     8*8    /* every char takes 8 consecutive bytes */
  232. };
  233.  
  234. static struct GfxLayout bulletlayout =
  235. {
  236.     /* there is no gfx ROM for this one, it is generated by the hardware */
  237.     3,3,    /* 3*3 box */
  238.     1,    /* just one */
  239.     1,    /* 1 bit per pixel */
  240.     { 8*8 },
  241.     { 2, 2, 2 },   /* I "know" that this bit of the */
  242.     { 2, 2, 2 },   /* graphics ROMs is 1 */
  243.     0    /* no use */
  244. };
  245.  
  246.  
  247. static struct GfxDecodeInfo gfxdecodeinfo[] =
  248. {
  249.     { REGION_GFX1, 0, &charlayout,   0, 64 },
  250.     { REGION_GFX1, 0, &bulletlayout, 0, 64 },
  251.     { -1 } /* end of array */
  252. };
  253.  
  254.  
  255.  
  256. static const char *tankbatt_sample_names[] =
  257. {
  258.     "*tankbatt",
  259.     "fire.wav",
  260.     "engine1.wav",
  261.     "engine2.wav",
  262.     "explode1.wav",
  263.     0    /* end of array */
  264. };
  265.  
  266. static struct Samplesinterface samples_interface =
  267. {
  268.     3,    /* 3 channels */
  269.     25,    /* volume */
  270.     tankbatt_sample_names
  271. };
  272.  
  273.  
  274.  
  275. static struct MachineDriver machine_driver_tankbatt =
  276. {
  277.     /* basic machine hardware */
  278.     {
  279.         {
  280.             CPU_M6502,
  281.             1000000,    /* 1 Mhz ???? */
  282.             readmem,writemem,0,0,
  283.             tankbatt_interrupt,1
  284.         }
  285.     },
  286.     60, DEFAULT_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  287.     1,
  288.     0,
  289.  
  290.     /* video hardware */
  291.     32*8, 32*8, { 0*8, 32*8-1, 2*8, 30*8-1 },
  292.     gfxdecodeinfo,
  293.     65, 128,
  294.     tankbatt_vh_convert_color_prom,
  295.  
  296.     VIDEO_TYPE_RASTER,
  297.     0,
  298.     generic_vh_start,
  299.     generic_vh_stop,
  300.     tankbatt_vh_screenrefresh,
  301.  
  302.     /* sound hardware */
  303.     0,0,0,0,
  304.     {
  305.         {
  306.             SOUND_SAMPLES,
  307.             &samples_interface
  308.         }
  309.     }
  310. };
  311.  
  312.  
  313.  
  314. /***************************************************************************
  315.  
  316.   Game driver(s)
  317.  
  318. ***************************************************************************/
  319.  
  320. ROM_START( tankbatt )
  321.     ROM_REGION( 0x10000, REGION_CPU1 )    /* 64k for code */
  322.     ROM_LOAD( "tb1-1.bin",    0x6000, 0x0800, 0x278a0b8c )
  323.     ROM_LOAD( "tb1-2.bin",    0x6800, 0x0800, 0xe0923370 )
  324.     ROM_LOAD( "tb1-3.bin",    0x7000, 0x0800, 0x85005ea4 )
  325.     ROM_LOAD( "tb1-4.bin",    0x7800, 0x0800, 0x3dfb5bcf )
  326.     ROM_RELOAD(               0xf800, 0x0800 )    /* for the reset and interrupt vectors */
  327.  
  328.     ROM_REGION( 0x0800, REGION_GFX1 | REGIONFLAG_DISPOSE )
  329.     ROM_LOAD( "tb1-5.bin",    0x0000, 0x0800, 0xaabd4fb1 )
  330.  
  331.     ROM_REGION( 0x0100, REGION_PROMS )
  332.     ROM_LOAD( "tankbatt.clr", 0x0000, 0x0100, 0x1150d613 )
  333. ROM_END
  334.  
  335.  
  336.  
  337. GAME( 1980, tankbatt, 0, tankbatt, tankbatt, 0, ROT90, "Namco", "Tank Battalion" )
  338.